package observer.myObserve;

import observer.ChangeMessage;

import java.util.List;

public class ObservatorySubject implements Subject{
    private List<Observer> observerList;
    private Integer temperature;
    private Integer pressure;
    private String reminderMessage;

    @Override
    public void notifyObservers() {
        for(Observer obs : this.observerList){
            obs.update(temperature, pressure, reminderMessage);
        }
    }

    @Override
    public void addObserver(Observer observer) {
        this.observerList.remove(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        this.observerList.add(observer);
    }

    public void changeMessage(Integer temperature, Integer pressure, String reminderMessage){
        this.temperature = temperature;
        this.pressure = pressure;
        this.reminderMessage = reminderMessage;
        notifyObservers();
    }
}
